package com.linln.modules.member.service.impl;

import com.linln.common.data.PageSort;
import com.linln.modules.member.domain.MemberAgentMoney;
import com.linln.modules.member.domain.MemberAgentMoneyChange;
import com.linln.modules.member.repository.MemberAgentMoneyChangeRepository;
import com.linln.modules.member.service.MemberAgentMoneyChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberAgentMoneyChangeServiceImpl implements MemberAgentMoneyChangeService {

    @Autowired
    private MemberAgentMoneyChangeRepository memberAgentMoneyChangeRepository;

    @Override
    public MemberAgentMoneyChange saveMemberAgentMoneyChange(MemberAgentMoneyChange MemberAgentMoneyChange) {
        MemberAgentMoneyChange save = memberAgentMoneyChangeRepository.save(MemberAgentMoneyChange);
        return save;
    }

    @Override
    public Page<MemberAgentMoneyChange> selectMemberAgentMoneyChange(MemberAgentMoneyChange emberAgentMoneyChange) {
        // 创建匹配器，进行动态查询匹配
        ExampleMatcher matcher = ExampleMatcher.matching();
        // 获取数据列表
        Example<MemberAgentMoneyChange> example = Example.of(emberAgentMoneyChange, matcher);
        PageRequest page = PageSort.pageRequest();
        Page<MemberAgentMoneyChange> all = memberAgentMoneyChangeRepository.findAll(example, page);
        return all;
    }
}
